package main

import (
	"context"
	"fmt"
	_ "github.com/mbobakov/grpc-consul-resolver" // It's important  //负债均衡  必须引入 ！！！！！！！！！
	"go.uber.org/zap"
	"google.golang.org/grpc"
	protopb "service_base_shop/address_srv/proto"
)

func main()  {
	userConn, err := grpc.Dial(
		fmt.Sprintf("consul://%s:%d/%s", "192.168.101.170",8500,"address_srv"),
		grpc.WithInsecure(),
		grpc.WithDefaultServiceConfig(`{"loadBalancingPolicy": "round_robin"}`),
		//grpc.WithChainUnaryInterceptor((otgrpc.OpenTracingClientInterceptor(opentracing.GlobalTracer()))), //修改源码 达到要求
	)
	if err != nil {
		zap.S().Fatal("user_srv链接失败")
	}
	c :=  protopb.NewAddrssClient(userConn)
	//data,err1 := c.GetUserAddr(context.Background(),&protopb.GetUserAddrListReq{ID: 4})
	//fmt.Println(err1,data.AddrList)
	//data,err1 := c.SetDefault(context.Background(),&protopb.SetDefaultReq{UserID: 4,AddrID: 5})
	//fmt.Println(err1,data)
	//data,err1 := c.DelAddr(context.Background(),&protopb.DelReq{UserID: 4,AddrID: 5})
	//fmt.Println(err1,data)
	//data,err1 := c.GetProvince(context.Background(),&protopb.GetProvinceAddrList{})
	//fmt.Println(err1,data)
	//data,err1 := c.GetCityAddr(context.Background(),&protopb.GetCityAddrList{ShengId: 2})
	//fmt.Println(err1,data)
	//data,err1 := c.GetAreaAddr(context.Background(),&protopb.GetAreaAddrList{ShengId: 22,CityId: 1})
	//fmt.Println(err1,data)

	data,err1 := c.AddAddr(context.Background(),&protopb.Addr{Sheng: 22})
	fmt.Println(err1,data)
}
